import webapp2
import ext

class MainPage(ext.SlotHandler):
	def get(self):
			
		# Run this to clear the database
		ext.clearDb()
		
		# Run these to create the test calendars
		# You only need to do this once unless you mess with the calendars and 
		# want to recreate them. They will be stored on your local datastore. 
		ext.createTestCalOpen()		
		# ext.createTestCalClosed()
		
		# Begin creating webpage
		self.response.out.write("<h1>Welcome to SlotMe-N!</h1>")
		
		
		cal = ext.Calendar.all().get();
		self.printCal(cal)
		
		# Print DB
#		self.printDb()
		
		
		# Make list of all accounts
		#accounts = [account for account in ext.Account.all()] 
		
		# Process all shifts
		# for shift in ext.Shift.all():
		# shift.up4grab = False
		# shift.put()
		
		# "What happens in class, stays in class" -ALK 3/7/12
		
		# Show all users
		# getusr = ext.Account.all().fetch(2)
		# for us in getusr:
		# self.response.out.write("email = %s; name = %s; key = %s <br/>" % (us.email, us.name, us.key()))
		# Assign them to shift
		# sh.availAccounts.append(us.key())
		# us.delete()
		
		# self.response.out.write("avaliable users: %s <br/>" % len(sh.availAccounts))
		# for k in sh.availAccounts:
		# av = db.get(k)
		# self.response.out.write("name = " + av.name + "<br/>")
		# self.response.out.write(k)
		# self.response.out.write('<br/>')
		
		# sh.put()
		
		# "That's not the aspect I have slides for" - ALK 4/23/12
		
		# cal = ext.Calendar()
		# cal.name = "OrangeKey"
		# admin = 'spollard@gmail.com'
		# query = db.GqlQuery("SELECT * FROM ext.Account WHERE email = :1", admin)
		# adminUsr = query.get()
		# cal.admin = adminUsr.key()
		
		# cal.shifts.append(db.Key('agxkZXZ-c2xvdG1lLW5yCwsSBVNoaWZ0GCEM'))
		
		# cal.put()
		
		# You can tell I stopped going to class as often because the spacing 
		# between quotes gets longer as the semester progresses, and we all know
		# that the quotes were uddered even when I wasn't there. 
		self.response.out.write("<h1>Done!</h1>")
	
		
app = webapp2.WSGIApplication([('/cp', MainPage)],
                              debug=True)